package com.shiwaixiangcun.customer.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shiwaixiangcun.customer.R;
import com.shiwaixiangcun.customer.entity.DeviceType;

import java.util.List;

/**
 * Author   Administrator
 * Date     2017/12/21
 * Desc     智能设备List
 *
 * @author Administrator
 */

public class AdapterDeviceList extends BaseQuickAdapter<DeviceType, BaseViewHolder> {
    public AdapterDeviceList(@Nullable List<DeviceType> data) {
        super(R.layout.item_intelligent_device, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DeviceType item) {
        helper.setText(R.id.tv_title, item.getTitle());
        helper.setText(R.id.tv_status, item.getDesc());
        if (item.getType() == 2) {
            helper.getView(R.id.tv_device_info).setVisibility(View.GONE);
        } else {
            helper.getView(R.id.tv_device_info).setVisibility(View.VISIBLE);
            helper.setText(R.id.tv_device_info, "剩余电量" + item.getRemainingPower() + "%");
        }
        ImageView imageview = helper.getView(R.id.iv_cover);
        Glide.with(mContext).load(item.getCover()).into(imageview);

    }

    public void clear() {

        mData.clear();
        this.notifyDataSetChanged();
    }
}
